import java.text.SimpleDateFormat;
import java.util.Date;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


public class Testing extends TestCase
{
	public Testing(String name)
	{
		super(name);
		testMakeBooking();
	}
	
	/**
	 * Testcase that makes a booking (which is a testvector) and then tries to confirm whether the booking has made (another testvector)
	 * if the confirmation succeeds, the test is positive
	 */
	public void testMakeBooking()
	{
		Airline airline = new Airline(false);
		
		 SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		 SimpleDateFormat timeFormat = new SimpleDateFormat("k:m");
		 
		 try
		 {
			 Date date = dateFormat.parse("07/07/2011");
			 airline.addPerson(new Person(1,"Tim Strijdhorst"));
			 airline.addPassenger(new PassengerRole(airline.getPersonFromID(1)));
			 airline.addRegularFlight(new RegularFlight(timeFormat.parse("12:00"), 1, 10));
			 RegularFlight regularFlight = airline.getRegularFlightFromFlightNumber(1);
			 regularFlight.addSpecificFlight(date);
			 
			 PassengerRole passenger = airline.getPassengerFromPerson(airline.getPersonFromID(1));
			 passenger.makeBooking(regularFlight.getSpecificFlightByDate(date));
			 
			 assertTrue(regularFlight.getSpecificFlightByDate(date).checkIfBookingExists(passenger) != null);
		 }
		 catch(Exception e)
		 {
			 e.printStackTrace();
		 }
	}
	
	public static Test suite()
	{
		return new TestSuite(Testing.class);
	}
}
